#ifndef __MEMORYPOOL_H__
#define __MEMORYPOOL_H__

#include "env.h"

using namespace WServer::GData;

#define MEMORYPOOLSIZE 32168

struct MemoryPoolData {
	bool bstatus;
	char data[MEMORYPOOLSIZE];
	MemoryPoolData() {bstatus = 0;memset(data, 0, MEMORYPOOLSIZE);}
};

class MemoryPool
{
public:
	MemoryPool();
	~MemoryPool();
	void initMemoryPool();
	int applyMemoryPool();
	int applyMemoryPool(int size);
	void releaseMemoryPool(int index);
	int getFreeCount();
	void reset(int index);

	static MemoryPool* s_instance;
	static MemoryPool* instance();
	_wserVector<MemoryPoolData*> m_memoryPool;
protected:
	pthread_mutex_t m_memoryMutex;
	int lastpos;
};

#endif //__MEMORYPOOL_H__
